fs/iso9660: Fix invalid free
authorMichael Chang <mchang@suse.com>
Fri, 31 May 2024 07:14:42 +0000 (15:14 +0800)
committerFelix Zielcke <fzielcke@z-51.de>
Thu, 3 Jul 2025 16:35:51 +0000 (18:35 +0200)
commit37243ccfead93ced1f438a344b12f727c05b8f17
tree7407cddae6dd5db74f17ca8dfcc17e2883d9774b
parentef174503e8f5374ff539129391284c5edc009a60
fs/iso9660: Fix invalid free

The ctx->filename can point to either a string literal or a dynamically
allocated string. The ctx->filename_alloc field is used to indicate the
type of allocation.

An issue has been identified where ctx->filename is reassigned to
a string literal in susp_iterate_dir() but ctx->filename_alloc is not
correctly handled. This oversight causes a memory leak and an invalid
free operation later.

The fix involves checking ctx->filename_alloc, freeing the allocated
string if necessary and clearing ctx->filename_alloc for string literals.

Reported-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Michael Chang <mchang@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Gbp-Pq: Topic cve-2025-jan
Gbp-Pq: Name fs-iso9660-Fix-invalid-free.patch
grub-core/fs/iso9660.c